﻿using Basic.FlowGatewayModule.Interface;
using Basic.FlowGatewayModule.Model;
using Basic.FlowRemoteModel;
using Basic.FlowRemoteModel.FlowApp.Model;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.FlowGatewayModule.Api
{
    [ApiRouteName("/flow/app/{name}")]
    internal class FlowAppApi : ApiController
    {
        private readonly IFlowAppService _Service;

        public FlowAppApi ( IFlowAppService service )
        {
            this._Service = service;
        }
        [ApiPower("all", "flow.app.set")]
        public bool SetSettleForm ( LongNullParam<long?> set )
        {
            return this._Service.SetSettleFormId(set.Id, set.Value);
        }
        public FlowApp[] GetList ( FlowAppType? appType )
        {
            return this._Service.GetList(appType);
        }
        [ApiPower("all", "flow.app.delete")]
        public void Delete ( [NumValidate("flow.app.id.error", 1)] long id )
        {
            this._Service.Delete(id);
        }
        [ApiPower("all", "flow.app.add")]
        public long Add ( FlowAppSet data )
        {
            return this._Service.Add(data);
        }
        [ApiPower("all", "flow.app.set")]
        public bool Enable ( [NumValidate("flow.app.id.error", 1)] long id )
        {
            return this._Service.Enable(id);
        }

        public FlowAppBase Get ( [NumValidate("flow.app.id.error", 1)] long id )
        {
            return this._Service.Get(id);
        }

        public PagingResult<FlowAppData> Query ( PagingParam<FlowAppQuery> param )
        {
            return this._Service.Query(param);
        }

        [ApiPower("all", "flow.app.set")]
        public bool Set ( LongParam<FlowAppSet> obj )
        {
            return this._Service.Set(obj.Id, obj.Value);
        }
        [ApiPower("all", "flow.app.set")]
        public bool SetFlow ( LongParam<AppFlowSet> obj )
        {
            return this._Service.SetFlow(obj.Id, obj.Value);
        }
        [ApiPower("all", "flow.app.set")]
        public bool Stop ( [NumValidate("flow.app.id.error", 1)] long id )
        {
            return this._Service.Stop(id);
        }
    }
}
